package logic.moves;

import java.io.Serializable;

import logic.Country;
import logic.Player;

@Deprecated
public class ConquerMove implements GameMove, Serializable  {
	
	private static final long serialVersionUID = 1L;

	public static final String move_type = "CONQUERMOVE";
	
	private 	Country 	invadedCountry;
	private		Country 	invadingCountry;
	private		Player		conqueror;
	private		boolean		moved;
	
	private		Player		conquered;
	private		SettleMove	settle;	
	
	

	

	/**
	 * @param invadedCountry
	 * @param invadingCountry
	 * @param conqueror
	 */
	public ConquerMove(Country invadedCountry, Country invadingCountry,
			Player conqueror) {
		super();
		this.invadedCountry = invadedCountry;
		this.invadingCountry = invadingCountry;
		this.conqueror = conqueror;
		this.moved = false;
		this.conquered = invadedCountry.getOwner();
	}

	 
	public boolean hasMoved() {
		return this.moved;
	}

	 
	public boolean makeMove() {
		this.invadedCountry.getOwner().removeCountry(this.invadedCountry);
		this.conqueror.addCountry(this.invadedCountry);
		this.invadingCountry.moveSoldiers(this.invadedCountry, 1);
		this.moved = true;
		return true;
	}

	 
	public void printDoMove() {
		
	}

	 
	public void printUndoMove() {
		
	}

	 
	public void restore() {
		this.invadedCountry.getOwner().removeCountry(this.invadedCountry);
		this.conquered.addCountry(this.invadedCountry);
		this.invadedCountry.moveSoldiers(this.invadingCountry, 1);
		this.moved = false;
	}
	
	public boolean isLegalMove(){
		boolean cond1 = !this.conqueror.equals(this.invadedCountry.getOwner());
		boolean cond2 = this.invadedCountry.getNeighbors().containsValue(this.invadingCountry);
		boolean cond3 = ((this.invadingCountry.getSoldiers() > 0) && (this.invadedCountry.getSoldiers() == 0));
		return (cond1 && cond2 && cond3);
	}


	/**
	 * @return move type as string
	 */
	public String getType() {
		return move_type;
	}

	public String getBriefDo() {
		return null;
	}

	public String getBriefUndo() {
		return null;
	}


	public void printShortDescription() {
		
	}

}
